package cn.bsuc.crm.service.impl;

import cn.bsuc.crm.dto.CustomerseverDTO;
import cn.bsuc.crm.entity.CustomerServe;
import cn.bsuc.crm.entity.User;
import cn.bsuc.crm.mapper.CustomerServeMapper;
import cn.bsuc.crm.service.CustomerServeService;
import cn.bsuc.crm.vo.CustomerServeVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhuoyuan
 * @since 2022-10-03
 */
@Service
public class CustomerServeServiceImp extends ServiceImpl<CustomerServeMapper, CustomerServe> implements CustomerServeService {
@Resource
private CustomerServeMapper customerServeMapper;



    @Override
    public Page<CustomerServeVO> CustomerServeByParams(Integer pageNo, Integer pageSize, CustomerseverDTO customerseverDTO) {
        Page<CustomerServeVO> page = new Page<>(pageNo, pageSize);
        return customerServeMapper.selectByParams(page,customerseverDTO) ;
    }

    @Override
    public Page<CustomerServe> selectAllServe(Integer pageNo, Integer pageSize) {
        Page<CustomerServe> objectPage = new Page<>(pageNo, pageSize);
        Page<CustomerServe> userPage = baseMapper.selectPage(objectPage, null);
        return userPage;
    }

    @Override
    public int insertAdd(CustomerServe customerServe) {
        LocalDateTime now = LocalDateTime.now();
        customerServe.setCreateDate(now);
        customerServe.setUpdateDate(now);
        if(customerServe.getId() == null) {
            return baseMapper.insert(customerServe);
        }else {
            return 0;
        }
    }

    @Override
    public int updateService(CustomerServe customerServe) {
        return baseMapper.updateById(customerServe);
    }

    @Override
    public List<CustomerServe> selectchuli(String username) {
        return customerServeMapper.selectchuli(username);
    }


}



